Skip to content

fix(router): 7 bugs in @ruvector/router — broken wrapper, score inversion, DB crashes#333

Merged
ruvnet merged 2 commits intomainfrom
fix/router-bugs-332
Apr 6, 2026
Merged

fix(router): 7 bugs in @ruvector/router — broken wrapper, score inversion, DB crashes#333
ruvnet merged 2 commits intomainfrom
fix/router-bugs-332

Conversation

@ruvnet
Copy link
Copy Markdown
Owner

@ruvnet ruvnet commented Apr 6, 2026

Summary

Fixes #332 — 7 bugs in @ruvector/router that made SemanticRouter completely non-functional through the wrapper and partially broken when used directly.

  • Critical: wrapper passed wrong property name (dimensions vs dimension) — constructor always threw
  • Critical: wrapper called non-existent methods (addRoute, match, matchTopK, removeRoute)
  • High: native module returns distances (0=identical) but JS filtered as similarities (1=identical) — routing always returned empty
  • High: fresh DB crashed on count()/get() — redb tables don't exist until first write
  • High: multiple VectorDb instances fought over ./vectors.db file lock
  • Medium: addIntentAsync silently dropped intents without embedder or embedding
  • Medium: version mismatch — package 0.1.28, platform deps pinned to 0.1.27

Files Changed

Area Files Changes
JS wrapper router-wrapper.ts/js/d.ts Fix property name, align with actual API, add setEmbedder/matchWithEmbedding
JS router router/index.js Distance→similarity conversion, dimension validation, error on missing embedder
Rust core storage.rs Handle TableDoesNotExist in all read methods
Rust FFI lib.rs Unique temp DB path per instance
Versions package.json ×6 Align all platform packages to 0.1.28
CI build-router.yml --cargo-cwd--manifest-path

Test plan

  • node npm/packages/router/test.js — all checks pass locally (darwin-arm64)
  • CI builds all 5 platforms (linux-x64, linux-arm64, darwin-x64, darwin-arm64, win32-x64)
  • CI publishes platform packages + main package to npm
  • Verify npm install @ruvector/router resolves correct platform binary

Test Results (local)

✓ VectorDb instance created (384 dimensions, cosine distance, in-memory)
✓ count(): 0
✓ insert() worked
✓ search() returned 1 result(s)
✓ SemanticRouter instance created
✓ addIntent() worked
✓ routeWithEmbedding() returned 1 result(s)
  Top result: test-intent (score: 1.0000)

🤖 Generated with claude-flow

Reuven and others added 2 commits April 6, 2026 16:16
Fixes #332

Critical:
- router-wrapper.ts: `dimensions` → `dimension` (constructor always threw)
- router-wrapper.ts: align with actual SemanticRouter API (addIntent,
  route, routeWithEmbedding, removeIntent)

High:
- index.js: convert native distance scores to similarity (0→1 scale)
- storage.rs: handle TableDoesNotExist on fresh DB reads
- lib.rs (FFI): unique temp DB path per instance (no lock conflicts)

Medium:
- index.js: addIntentAsync throws on missing embedder+embedding
- index.js: load() validates dimension mismatch
- package.json: align all platform deps to 0.1.28

CI:
- build-router.yml: --cargo-cwd → --manifest-path for newer napi-rs

Co-Authored-By: claude-flow <ruv@ruv.net>
The CI devDependency @napi-rs/cli ^2.18.0 uses --cargo-cwd.
--manifest-path is v3.x only.

Co-Authored-By: claude-flow <ruv@ruv.net>
@ruvnet ruvnet merged commit 794548a into main Apr 6, 2026
13 checks passed
ruvnet added a commit that referenced this pull request Apr 6, 2026
The router-wrapper was already fixed in #333 but the ruvector
package version wasn't bumped for npm publish.

Co-Authored-By: claude-flow <ruv@ruv.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(router): 7 bugs in @ruvector/router — broken wrapper, score inversion, DB crashes

1 participant